<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">


<head>
	<title>WithDrawal Form</title>
	
	<meta charset="utf-8" />
	<link rel="stylesheet" type="text/css" href="css/popup_css.css" />
	<link rel="stylesheet" href="css/withdrawal.css" type="text/css"  />
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
	
<script type="text/javascript">
$(document).ready(function() { 

	$('#close').click(function(){
        parent.history.back();
        return false;
    });
	
	$("#send").click(function(event) { 
		
		var req=0;

		 if(document.getElementById('pnameErrorLable').innerHTML!=""){
			req=1;
		}
		 else if(document.getElementById('ifscErrorLable').innerHTML!=""){
				req=1;
			}
		 else if(document.getElementById('bnameErrorLable').innerHTML!=""){
				req=1;
			}
		 else if(document.getElementById('wmodeErrorLable').innerHTML!=""){
				req=1;
			}
		 else if(document.getElementById('accnoErrorLable').innerHTML!=""){
				req=1;
			}
		 else if(document.getElementById('umailErrorLable').innerHTML!=""){
				req=1;
			}
		 else if(document.getElementById('amountErrorLable').innerHTML!=""){
				req=1;
			}
		
		
		if(req=0){			
	var reqUrl="./bank/withdrawl";
	var withdrawJson=JSON.stringify({"fname":$("#fname").val(),"emailid":$("#emailid").val(),"ifsc":$("#ifsc").val(),
		"accno":$("#accno").val(),"bname":$("#bname").val(),"w_mode":$("#w_mode").val(),"amount":$("#amount").val(),
		"comments":$("#comments").val()});
	$.ajax(
		  {
		  type: "POST",
		  url: reqUrl,
		  dataType: "json",
		  contentType: 'application/json',
		  data:withdrawJson ,
		  success: function(html) { 			 
		   }
		  
		});
	 event.preventDefaults();
	 }
	});
	
	$.ajax({
		url : './broker/getBrokerDetail',
		dataType: "json",
		contentType: 'application/json',			    
		success : function(jsonData) {
				for(var a in jsonData){
				
				document.getElementById("emailid").value=jsonData[a]["emailID"];
				document.getElementById("fname").value=jsonData[a]["fname"]+" "+jsonData[a]["lname"];
				
			}

		
		
		}
	});
	
	$.ajax({
		url : './broker/getExchangeDetail',
		dataType: "json",
		contentType: 'application/json',			    
		success : function(jsonData) {
			for(var a in jsonData){
				document.getElementById("bname").value=jsonData[a]["bname"];
				document.getElementById("accno").value=jsonData[a]["accno"];
				document.getElementById("ifsc").value=jsonData[a]["ifsc"];	
			}
		}
	});
	
});

function formvalidation(){
	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var alpha_num_check = /^([a-zA-Z0-9\s])+$/;
	var alpha_check = /^([a-zA-Z\.\s])+$/;
	var phone_check= /\(?\d{2}\)?([-\/\.])\d{3}\1\d{4}/;
	var website_check= /^(http|ftp):\/\/(www\.)?.+\.(com|net|org)$/;
	var error	=	false;
	
	document.getElementById('pnameErrorLable').innerHTML="";
	document.getElementById('ifscErrorLable').innerHTML="";
	document.getElementById('bnameErrorLable').innerHTML="";
	document.getElementById('accnoErrorLable').innerHTML="";
	document.getElementById('umailErrorLable').innerHTML="";
	document.getElementById('amountErrorLable').innerHTML="";
	document.getElementById('wmodeErrorLable').innerHTML="";
	
		 if((document.getElementById('emailid').value)==''){
			document.getElementById('umailErrorLable').innerHTML='*Enter  E-mail id.';
			error	=	true;
		}
			if((document.getElementById('fname').value)==''){
			document.getElementById('pnameErrorLable').innerHTML='*Enter First name.';
			error	=	true;
		}
			
			if((document.getElementById('ifsc').value)==''){
				document.getElementById('ifscErrorLable').innerHTML='*Enter IFSC Code.';
				error	=	true;
			}
			if((document.getElementById('accno').value)==''){
				document.getElementById('accnoErrorLable').innerHTML='*Enter Account Number.';
				error	=	true;
			}
			if((document.getElementById('bname').value)==''){
				document.getElementById('bnameErrorLable').innerHTML='*Enter  Bank Name.';
				error	=	true;
			}
			if((document.getElementById('amount').value)==''){
				document.getElementById('amountErrorLable').innerHTML='*Enter Amount.';
				error	=	true;
			}
			
			if((document.getElementById('w_mode').value)==''){
				document.getElementById('wmodeErrorLable').innerHTML='*Select any payment mode.';
				error	=	true;
			}
		
		if(error==false){
			return true;
			}else{ 
			return false;
		}
}

function isNumberKey(evt){
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;
    return true;
}
</script>

 <style>
 .centerpart{
 width: 1000px;
height: 570px;
background: none repeat scroll 0% 0% #FFF;
margin: 4px 0px 0px 145px;
float: left;
padding: 0px;
border-radius: 10px;
 }

 </style>
</head>
 
<body>
<%@ include file="header.jsp" %>
 <div class="centerpart">
<div style="margin-left:35px; margin-top:23px;">	<h2>Broker Fund Transfer Form</h2></div>
<div style="margin-left:28px; margin-top:-12px;" >     <p>To transfer  funds from your account, please complete and submit the form below.<br>

A fund transfer request will be processed only if you have sufficient available funds. If you traded today, the funds will not be available to fund transfer until the following business day.<br>

Please note: In accordance with anti-money laundering regulations, all funds transfer will be sent from the name on the account.</p>

	</div>
	<form  method="post" name="withdraw" id="withdrawal" class="form"  action="./BfundTransfer">
		
		<div class="name" id="field1">
        
        	<div class="field2">
			<label for="name" class="label-field">ClientID</label><sec:authentication property="principal.username"/> <!-- <input type="text" name="user_Id" id="user_Id" placeholder="Enter your first name" /> -->
            </div>
            
            <div class="field2">
			<label for="name" class="label-field1">Client Name<b><font color="red" size="3">*</font></b></label> 
			<input type="text" name="fname" id="fname" placeholder="Enter your last name" required/>
            <div id="pnameErrorLable" style="text-align: right;"></div></div>
		</div>
		<div class="name" id="field1">
        
        	<div class="field2">
			<label for="name" class="label-field">Email<b><font color="red" size="3">*</font></b></label> 
			<input type="text" name="emailid" id="emailid" placeholder="mail@example.com" required/>
            <div id="umailErrorLable" style="text-align: right;"></div></div>
            
            <div class="field2">
			<label for="name" class="label-field1">IFSC CODE<b><font color="red" size="3">*</font></b></label> 
			<input type="text" name="ifsc" id="ifsc" placeholder="Enter IFSC Code"  required/>
            <div id="ifscErrorLable" style="text-align: right;"></div></div>
		</div>		
		
		
		<div class="web" id="field1">
        	<div class="field2">
				<label for="web" class="label-field">Bank Account Number<b><font color="red" size="3">*</font></b></label> 
				<input type="text" name="accno" id="accno" placeholder="Your account number" onkeypress="return isNumberKey(event)" required/>
			<div id="accnoErrorLable" style="text-align: right;"></div></div>
            
            <div class="field2">
				<label for="email" class="label-field1">Bank Name<b><font color="red" size="3">*</font></b></label>
                	<input type="text" name="bname" id="bname" placeholder="Your Bank Name" required/>
			<div id="bnameErrorLable" style="text-align: right;"></div></div>
		</div>	
        
        <div class="web" id="field1">
        	<div class="field2">
				<label for="web" class="label-field">Amount<b><font color="red" size="3">*</font></b></label>
				<input type="text" name="amount" id="amount" placeholder="Enter Amount" onkeypress="return isNumberKey(event)" required/>
			<div id="amountErrorLable" style="text-align: right;"></div></div>
            
            <div class="field2">
				<label for="email" class="label-field1">Currency</label>
				<select name="currency" class="select" id="currency">                	
                <option>NPR</option>                   
               </select>
			</div>
		</div>	
        
        <div class="web" id="field1">
		
            <label for="email" class="label-field">Withdrawal Method<b><font color="red" size="3">*</font></b></label> 
            <div class="field2">
			<select id="w_mode" onchange="" style="margin-left:0;margin-right:5px;width:219px;border:1px solid #D6D8DA; height:30px; padding:5px; font-size:12px; color:#333333;" name="idproof" required>
                        <option value="Check">Check (sent to address on file)</option>
                        
            </select>
                        <div id="wmodeErrorLable"></div> </div>
		</div>
	
		<div class="text" id="field1">
			<label for="email" class="label-field">Additional Comments </label>
			<textarea name="text" placeholder="Write something to us" id="comments"></textarea>
		</div>
		
		<div class="submit" id="field1" >
			<input type="button" value="Send" id="send" name="send" onclick="formvalidation();"/>
			<a href="home"><input class="button" type="button" value="Back" style="margin-left: 100px"></input></a>
		</div>
		
		<a class="close" href="#" id="close" style=" right: 207px; top: 111px;"></a>    
	</form>
</div>
</body>

</html>
